//part1:C03:ex3.20.2.cpp -- sum of first and last one.
#include <iostream>
#include <vector>

int main(void)
{
    using namespace std;
    vector<int> vInt;
    int iVal;
    cout << "Enter some integers:\n";
    while (cin >> iVal)
    {
        vInt.push_back(iVal);
    }
    if (vInt.size() == 0)
    {
        cout << "No datas!" << endl;
        return -1;
    }

    cout << "sum of first and last is :\n";
    for (decltype(vInt.size()) i = 0; i < vInt.size() / 2; i++) 
    {
        cout << vInt[i] + vInt[vInt.size() - i - 1] << " ";
        if ((i + 1) % 5 == 0)
        {
            cout << endl;
        }
    }
    if (vInt.size() % 2 != 0)
    {
        cout << vInt[vInt.size() / 2];
    }
    
    return 0;
}